/**
 * <copyright>
 * </copyright>
 *

 */
package hu.bme.mit.androtext.gui.androGui.impl;

import hu.bme.mit.androtext.gui.androGui.AndroGuiPackage;
import hu.bme.mit.androtext.gui.androGui.Preference;
import hu.bme.mit.androtext.gui.androGui.PreferenceEnabledAttribute;
import hu.bme.mit.androtext.gui.androGui.PreferenceKeyAttribute;
import hu.bme.mit.androtext.gui.androGui.PreferencePersistentAttribute;
import hu.bme.mit.androtext.gui.androGui.PreferenceSummaryAttribute;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Preference</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link hu.bme.mit.androtext.gui.androGui.impl.PreferenceImpl#getTitle <em>Title</em>}</li>
 *   <li>{@link hu.bme.mit.androtext.gui.androGui.impl.PreferenceImpl#getKey <em>Key</em>}</li>
 *   <li>{@link hu.bme.mit.androtext.gui.androGui.impl.PreferenceImpl#getSummary <em>Summary</em>}</li>
 *   <li>{@link hu.bme.mit.androtext.gui.androGui.impl.PreferenceImpl#getEnabled <em>Enabled</em>}</li>
 *   <li>{@link hu.bme.mit.androtext.gui.androGui.impl.PreferenceImpl#getPersistent <em>Persistent</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PreferenceImpl extends MinimalEObjectImpl.Container implements Preference
{
  /**
   * The default value of the '{@link #getTitle() <em>Title</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTitle()
   * @generated
   * @ordered
   */
  protected static final String TITLE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getTitle() <em>Title</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTitle()
   * @generated
   * @ordered
   */
  protected String title = TITLE_EDEFAULT;

  /**
   * The cached value of the '{@link #getKey() <em>Key</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getKey()
   * @generated
   * @ordered
   */
  protected PreferenceKeyAttribute key;

  /**
   * The cached value of the '{@link #getSummary() <em>Summary</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSummary()
   * @generated
   * @ordered
   */
  protected PreferenceSummaryAttribute summary;

  /**
   * The cached value of the '{@link #getEnabled() <em>Enabled</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEnabled()
   * @generated
   * @ordered
   */
  protected PreferenceEnabledAttribute enabled;

  /**
   * The cached value of the '{@link #getPersistent() <em>Persistent</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPersistent()
   * @generated
   * @ordered
   */
  protected PreferencePersistentAttribute persistent;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected PreferenceImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return AndroGuiPackage.Literals.PREFERENCE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getTitle()
  {
    return title;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTitle(String newTitle)
  {
    String oldTitle = title;
    title = newTitle;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AndroGuiPackage.PREFERENCE__TITLE, oldTitle, title));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public PreferenceKeyAttribute getKey()
  {
    return key;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetKey(PreferenceKeyAttribute newKey, NotificationChain msgs)
  {
    PreferenceKeyAttribute oldKey = key;
    key = newKey;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AndroGuiPackage.PREFERENCE__KEY, oldKey, newKey);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setKey(PreferenceKeyAttribute newKey)
  {
    if (newKey != key)
    {
      NotificationChain msgs = null;
      if (key != null)
        msgs = ((InternalEObject)key).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AndroGuiPackage.PREFERENCE__KEY, null, msgs);
      if (newKey != null)
        msgs = ((InternalEObject)newKey).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AndroGuiPackage.PREFERENCE__KEY, null, msgs);
      msgs = basicSetKey(newKey, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AndroGuiPackage.PREFERENCE__KEY, newKey, newKey));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public PreferenceSummaryAttribute getSummary()
  {
    return summary;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetSummary(PreferenceSummaryAttribute newSummary, NotificationChain msgs)
  {
    PreferenceSummaryAttribute oldSummary = summary;
    summary = newSummary;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AndroGuiPackage.PREFERENCE__SUMMARY, oldSummary, newSummary);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSummary(PreferenceSummaryAttribute newSummary)
  {
    if (newSummary != summary)
    {
      NotificationChain msgs = null;
      if (summary != null)
        msgs = ((InternalEObject)summary).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AndroGuiPackage.PREFERENCE__SUMMARY, null, msgs);
      if (newSummary != null)
        msgs = ((InternalEObject)newSummary).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AndroGuiPackage.PREFERENCE__SUMMARY, null, msgs);
      msgs = basicSetSummary(newSummary, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AndroGuiPackage.PREFERENCE__SUMMARY, newSummary, newSummary));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public PreferenceEnabledAttribute getEnabled()
  {
    return enabled;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetEnabled(PreferenceEnabledAttribute newEnabled, NotificationChain msgs)
  {
    PreferenceEnabledAttribute oldEnabled = enabled;
    enabled = newEnabled;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AndroGuiPackage.PREFERENCE__ENABLED, oldEnabled, newEnabled);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setEnabled(PreferenceEnabledAttribute newEnabled)
  {
    if (newEnabled != enabled)
    {
      NotificationChain msgs = null;
      if (enabled != null)
        msgs = ((InternalEObject)enabled).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AndroGuiPackage.PREFERENCE__ENABLED, null, msgs);
      if (newEnabled != null)
        msgs = ((InternalEObject)newEnabled).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AndroGuiPackage.PREFERENCE__ENABLED, null, msgs);
      msgs = basicSetEnabled(newEnabled, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AndroGuiPackage.PREFERENCE__ENABLED, newEnabled, newEnabled));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public PreferencePersistentAttribute getPersistent()
  {
    return persistent;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetPersistent(PreferencePersistentAttribute newPersistent, NotificationChain msgs)
  {
    PreferencePersistentAttribute oldPersistent = persistent;
    persistent = newPersistent;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AndroGuiPackage.PREFERENCE__PERSISTENT, oldPersistent, newPersistent);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPersistent(PreferencePersistentAttribute newPersistent)
  {
    if (newPersistent != persistent)
    {
      NotificationChain msgs = null;
      if (persistent != null)
        msgs = ((InternalEObject)persistent).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AndroGuiPackage.PREFERENCE__PERSISTENT, null, msgs);
      if (newPersistent != null)
        msgs = ((InternalEObject)newPersistent).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AndroGuiPackage.PREFERENCE__PERSISTENT, null, msgs);
      msgs = basicSetPersistent(newPersistent, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AndroGuiPackage.PREFERENCE__PERSISTENT, newPersistent, newPersistent));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case AndroGuiPackage.PREFERENCE__KEY:
        return basicSetKey(null, msgs);
      case AndroGuiPackage.PREFERENCE__SUMMARY:
        return basicSetSummary(null, msgs);
      case AndroGuiPackage.PREFERENCE__ENABLED:
        return basicSetEnabled(null, msgs);
      case AndroGuiPackage.PREFERENCE__PERSISTENT:
        return basicSetPersistent(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case AndroGuiPackage.PREFERENCE__TITLE:
        return getTitle();
      case AndroGuiPackage.PREFERENCE__KEY:
        return getKey();
      case AndroGuiPackage.PREFERENCE__SUMMARY:
        return getSummary();
      case AndroGuiPackage.PREFERENCE__ENABLED:
        return getEnabled();
      case AndroGuiPackage.PREFERENCE__PERSISTENT:
        return getPersistent();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case AndroGuiPackage.PREFERENCE__TITLE:
        setTitle((String)newValue);
        return;
      case AndroGuiPackage.PREFERENCE__KEY:
        setKey((PreferenceKeyAttribute)newValue);
        return;
      case AndroGuiPackage.PREFERENCE__SUMMARY:
        setSummary((PreferenceSummaryAttribute)newValue);
        return;
      case AndroGuiPackage.PREFERENCE__ENABLED:
        setEnabled((PreferenceEnabledAttribute)newValue);
        return;
      case AndroGuiPackage.PREFERENCE__PERSISTENT:
        setPersistent((PreferencePersistentAttribute)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case AndroGuiPackage.PREFERENCE__TITLE:
        setTitle(TITLE_EDEFAULT);
        return;
      case AndroGuiPackage.PREFERENCE__KEY:
        setKey((PreferenceKeyAttribute)null);
        return;
      case AndroGuiPackage.PREFERENCE__SUMMARY:
        setSummary((PreferenceSummaryAttribute)null);
        return;
      case AndroGuiPackage.PREFERENCE__ENABLED:
        setEnabled((PreferenceEnabledAttribute)null);
        return;
      case AndroGuiPackage.PREFERENCE__PERSISTENT:
        setPersistent((PreferencePersistentAttribute)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case AndroGuiPackage.PREFERENCE__TITLE:
        return TITLE_EDEFAULT == null ? title != null : !TITLE_EDEFAULT.equals(title);
      case AndroGuiPackage.PREFERENCE__KEY:
        return key != null;
      case AndroGuiPackage.PREFERENCE__SUMMARY:
        return summary != null;
      case AndroGuiPackage.PREFERENCE__ENABLED:
        return enabled != null;
      case AndroGuiPackage.PREFERENCE__PERSISTENT:
        return persistent != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (title: ");
    result.append(title);
    result.append(')');
    return result.toString();
  }

} //PreferenceImpl
